﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="oml", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Oml))]
    public class OmlSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IOml clazz;
        
        public OmlSerializer(IOml clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("gametabid");
            if (clazz.Gametabid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gametabid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gametabid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ofloat");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Ofloat))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("cfloat");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Cfloat))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("fill");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Fill))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("credit");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Credit))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("drop");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Drop))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("netwin");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Netwin))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="gametabid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oml>gametabid");
                }
                clazz.Gametabid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gametabid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oml>gametabid", Reader.LocalName);
            }
            if (Reader.LocalName=="ofloat") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oml>ofloat");
                }
                clazz.Ofloat = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("ofloat")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oml>ofloat", Reader.LocalName);
            }
            if (Reader.LocalName=="cfloat") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oml>cfloat");
                }
                clazz.Cfloat = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("cfloat")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oml>cfloat", Reader.LocalName);
            }
            if (Reader.LocalName=="fill") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oml>fill");
                }
                clazz.Fill = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("fill")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oml>fill", Reader.LocalName);
            }
            if (Reader.LocalName=="credit") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oml>credit");
                }
                clazz.Credit = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("credit")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oml>credit", Reader.LocalName);
            }
            if (Reader.LocalName=="drop") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oml>drop");
                }
                clazz.Drop = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("drop")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oml>drop", Reader.LocalName);
            }
            if (Reader.LocalName=="netwin") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oml>netwin");
                }
                clazz.Netwin = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("netwin")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oml>netwin", Reader.LocalName);
            }
        }
    }
}
